From 28bfe195942912cb81e03dc6d98b778f4df17a50 Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Sun, 17 Feb 2002 22:03:29 +0000 Subject: [PATCH] Don't set the PC_EXPLICIT flag for unused palette entries, that might have 2002-02-17 Tor Lillqvist * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the PC_EXPLICIT flag for unused palette entries, that might have undesired side effects. Just set them to black. Black is always present in a palette, so having superfluous black entries won't cause any extra allocations from the system palette either when realized. * gdk/win32/gdkevents-win32.c (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the system visual is static color, i.e. the user has told GDK to use just the 16 static colors. In that case no need to redraw anything, as the colors are static and by definition always correctly mapped in the system palette. (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. --- ChangeLog | 19 +++++++++++++++++++ ChangeLog.pre-2-0 | 19 +++++++++++++++++++ ChangeLog.pre-2-10 | 19 +++++++++++++++++++ ChangeLog.pre-2-2 | 19 +++++++++++++++++++ ChangeLog.pre-2-4 | 19 +++++++++++++++++++ ChangeLog.pre-2-6 | 19 +++++++++++++++++++ ChangeLog.pre-2-8 | 19 +++++++++++++++++++ gdk/win32/gdkcolor-win32.c | 25 ++++++++++++++++--------- gdk/win32/gdkevents-win32.c | 10 ++++++++-- 9 files changed, 157 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index eed75915ce..f49e751759 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index eed75915ce..f49e751759 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index eed75915ce..f49e751759 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index eed75915ce..f49e751759 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index eed75915ce..f49e751759 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index eed75915ce..f49e751759 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index eed75915ce..f49e751759 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,22 @@ +2002-02-17 Tor Lillqvist + + * gdk/win32/gdkcolor-win32.c (free_colors): Don't set the + PC_EXPLICIT flag for unused palette entries, that might have + undesired side effects. Just set them to black. Black is always + present in a palette, so having superfluous black entries won't + cause any extra allocations from the system palette either when + realized. + + * gdk/win32/gdkevents-win32.c + (gdk_event_translate:WM_QUERYNEWPALETTE): Don't do anything if the + system visual is static color, i.e. the user has told GDK to use + just the 16 static colors. In that case no need to redraw + anything, as the colors are static and by definition always + correctly mapped in the system palette. + (WM_PALETTECHANGED): Ditto, no need to call UpdateColors() either. + + * gtk/gtk.def: Add new gtkfilesel entry points. + 2002-02-17 Matthias Clasen * docs/tutorial/gtk-tut.sgml, examples/paned/paned.c, diff --git a/gdk/win32/gdkcolor-win32.c b/gdk/win32/gdkcolor-win32.c index 528ac67a12..2259857c07 100644 --- a/gdk/win32/gdkcolor-win32.c +++ b/gdk/win32/gdkcolor-win32.c @@ -454,8 +454,11 @@ free_colors (GdkColormap *cmap, GdkColormapPrivateWin32 *cmapp = GDK_WIN32_COLORMAP_DATA (cmap); gint i; #ifdef G_ENABLE_DEBUG - gint set_explicit = 0; + gint set_black_count = 0; #endif + gboolean *cleared_entries; + + cleared_entries = g_new0 (gboolean, cmap->size); /* We don't have to do anything for non-palette devices. */ @@ -470,7 +473,10 @@ free_colors (GdkColormap *cmap, else if (cmapp->use[pixels[i]] == GDK_WIN32_PE_STATIC) ; /* Nothing either*/ else - cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE; + { + cmapp->use[pixels[i]] = GDK_WIN32_PE_AVAILABLE; + cleared_entries[pixels[i]] = TRUE; + } } for (i = cmapp->current_size - 1; i >= 0; i--) if (cmapp->use[i] != GDK_WIN32_PE_AVAILABLE) @@ -484,25 +490,26 @@ free_colors (GdkColormap *cmap, else cmapp->current_size = i + 1; } + pe.peRed = pe.peGreen = pe.peBlue = pe.peFlags = 0; for (i = 0; i < cmapp->current_size; i++) { - if (cmapp->use[i] == GDK_WIN32_PE_AVAILABLE) + if (cleared_entries[i]) { - *(WORD*)&pe = i; - pe.peFlags = PC_EXPLICIT; if (!SetPaletteEntries (cmapp->hpal, i, 1, &pe)) WIN32_GDI_FAILED ("SetPaletteEntries"); - GDK_NOTE (COLORMAP, set_explicit++); + GDK_NOTE (COLORMAP, set_black_count++); } } #if 0 GDK_NOTE (COLORMAP, gdk_win32_print_hpalette (cmapp->hpal)); #else - GDK_NOTE (COLORMAP, (set_explicit > 0 ? - g_print ("free_colors: %d (%d) PC_EXPLICIT\n", - set_explicit, cmapp->current_size) + GDK_NOTE (COLORMAP, (set_black_count > 0 ? + g_print ("free_colors: %d (%d) set to black\n", + set_black_count, cmapp->current_size) : (void) 0)); #endif + g_free (cleared_entries); + break; default: diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 98859a1955..47df43ff02 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -2732,8 +2732,11 @@ gdk_event_translate (GdkEvent *event, case WM_QUERYNEWPALETTE: GDK_NOTE (EVENTS_OR_COLORMAP, g_print ("WM_QUERYNEWPALETTE: %p\n", msg->hwnd)); - synthesize_expose_events (window); - update_colors_counter = 0; + if (gdk_visual_get_system ()->type == GDK_VISUAL_PSEUDO_COLOR) + { + synthesize_expose_events (window); + update_colors_counter = 0; + } *ret_val_flagp = TRUE; *ret_valp = FALSE; break; @@ -2744,6 +2747,9 @@ gdk_event_translate (GdkEvent *event, *ret_val_flagp = TRUE; *ret_valp = FALSE; + if (gdk_visual_get_system ()->type != GDK_VISUAL_PSEUDO_COLOR) + break; + if (msg->hwnd == (HWND) msg->wParam) break; -- 2.30.2